''''
1、绘制云顶高度分布图
'''
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

# 读取数据
# data = pd.read_csv("ocean_merged_2020010104_11.15.csv")  # 替换为你的数据文件路径
# filtered_data_size = len(data)
# print(f'筛选前的数据总量为：{filtered_data_size}')
# data = data[data['fy_cbh'] >= 0]
# data = data[data['fy_cot'] >= 0]
# filtered_data_size = len(data)
# print(f'筛选后的数据总量为：{filtered_data_size}')

data = pd.read_csv("2020010104ocean_data.csv")  # 替换为你的数据文件路径
filtered_data_size = len(data)
print(f'筛选前的数据总量为：{filtered_data_size}')
data = data[data['fy_clm'] == 0]
filtered_data_size = len(data)
print(f'clm=0的数据总量为：{filtered_data_size}')
data = data[data['fy_clt'] != 7]
filtered_data_size = len(data)
print(f'clt!=7的数据总量为：{filtered_data_size}')



# 获取经纬度和云顶高度信息
latitude = data["fy_lat"]
longitude = data["fy_lon"]
cth = data["fy_cth"]

# 创建球面投影
plt.figure(figsize=(10, 10))
m = Basemap(projection='ortho', lat_0=0, lon_0=104.7, resolution='l')  # 以 (0, 104.7) 作为中心

# 绘制地图背景
m.drawcoastlines()
m.drawcountries()
# 添加经纬度线
parallels = range(-90, 91, 30)  # 每30度一个纬线
meridians = range(-180, 181, 30)  # 每30度一个经线
m.drawparallels(parallels, labels=[1, 0, 0, 0], color='gray', dashes=[1, 1], fontsize=10)
m.drawmeridians(meridians, labels=[0, 0, 0, 1], color='gray', dashes=[1, 1], fontsize=10)

# 将经纬度转换为地图坐标
x, y = m(longitude.values, latitude.values)

# 绘制云顶高度，使用散点图
# 这里我们使用云顶高度的值来设置点的颜色和大小
scatter = m.scatter(x, y, c=cth, s=50, cmap='Blues', marker='s',  alpha=0.7)


# 添加颜色条
plt.colorbar(scatter, label='Cloud Top Height (CTH)')

# 添加标题
plt.title('Cloud Top Height Distribution')

# 显示图形
plt.show()
#
#
# ''''
# 绘制云类型
# 绘制海岸线与边界线
# '''
# import pandas as pd
# import matplotlib.pyplot as plt
# from mpl_toolkits.basemap import Basemap
#
# # 读取数据
# data = pd.read_csv("2020010104ocean_data.csv")  # 替换为你的数据文件路径
# data = data[data['fy_cbh'] >= 0]
# data = data[data['fy_cot'] >= 0]
# # 获取经纬度和云类型信息
# latitude = data["fy_lat"]
# longitude = data["fy_lon"]
# clt = data["fy_clt"]
#
# # 云类型和颜色映射
# cloud_types = {
#     # 0: "Clear",
#     2: "Water Type",
#     3: "Super Cooled Type",
#     4: "Mixed Type",
#     5: "Ice Type",
#     6: "Cirrus Type",
#     7: "Overlap Type"
# }
#
# # 配置颜色
# colors = {
#     # 0: "lightblue",
#     2: "blue",
#     3: "cyan",
#     4: "green",
#     5: "purple",
#     6: "orange",
#     7: "red"
# }
#
# # 创建地图投影
# plt.figure(figsize=(12, 8))
# m = Basemap(projection='cyl', llcrnrlat=-80, urcrnrlat=80, llcrnrlon=20, urcrnrlon=180, resolution='l')
#
# # 绘制地图背景
# m.drawcoastlines()
# m.drawcountries()
# m.drawparallels(range(-80, 81, 20), labels=[1,0,0,0])
# m.drawmeridians(range(20, 181, 20), labels=[0,0,0,1])
#
# # 循环绘制不同云类型的数据
# for clt_type, clt_name in cloud_types.items():
#     x, y = m(longitude[clt == clt_type].values, latitude[clt == clt_type].values)
#     plt.scatter(x, y, c=colors[clt_type], label=clt_name, s=5, alpha=0.6)
#
# # 添加图例、标签和标题
# plt.legend(title="Cloud Types", loc='lower left')
# plt.title("Projected Cloud Type Distribution", fontsize=14)
#
# # 显示图形
# plt.show()

''''正射投影'''
# import pandas as pd
# import matplotlib.pyplot as plt
# from mpl_toolkits.basemap import Basemap
#
# # 读取数据
# # data = pd.read_csv("2020010104ocean_data.csv")  # 替换为你的数据文件路径
# data = pd.read_csv("ocean_merged_2020010104_11.15.csv")  # 替换为你的数据文件路径
# data = data[data['fy_cbh'] >= 0]
# data = data[data['fy_cot'] >= 0]
#
# # 获取经纬度和云类型信息
# latitude = data["fy_lat"]
# longitude = data["fy_lon"]
# clt = data["fy_clt"]
#
# # 云类型和颜色映射
# cloud_types = {
#     # 0: "Clear",
#     2: "Water Type",
#     3: "Super Cooled Type",
#     4: "Mixed Type",
#     5: "Ice Type",
#     6: "Cirrus Type",
#     # 7: "Overlap Type"
# }
#
# # 配置颜色
# # colors = {
# #     2: "#bcbd46",
# #     3: "#e8e8b9",
# #     4: "#86d3de",
# #     5: "#a5dfe7",
# #     6: "#d9d9d9"
# # }
# colors = {
#     # 0: "white",
#     2: "#ed8687",
#     3: "#feb29b",
#     4: "#ffd19d",
#     5: "#afdcef",
#     6: "#c6d59e"
#     # 7: "red"
# }
#
# # 创建球面投影
# plt.figure(figsize=(10, 10))
# m = Basemap(projection='ortho', lat_0=0, lon_0=104.7, resolution='l')  # 以 (0, 104.7) 作为中心
#
# # 绘制地图背景
# m.drawcoastlines()
# m.drawcountries()
#
# # 添加经纬度线
# parallels = range(-90, 91, 30)  # 每30度一个纬线
# meridians = range(-180, 181, 30)  # 每30度一个经线
# m.drawparallels(parallels, labels=[1, 0, 0, 0], color='gray', dashes=[1, 1], fontsize=10)
# m.drawmeridians(meridians, labels=[0, 0, 0, 1], color='gray', dashes=[1, 1], fontsize=10)
#
# # 循环绘制不同云类型的数据
# for clt_type, clt_name in cloud_types.items():
#     x, y = m(longitude[clt == clt_type].values, latitude[clt == clt_type].values)
#     plt.scatter(x, y, c=colors[clt_type], label=clt_name, s=5, alpha=0.6)
#
# # 添加图例和标题
# # plt.legend(title="Cloud Types", loc='lower left')
# plt.legend(title="Cloud Types", loc='lower left', bbox_to_anchor=(-0.1, 0), fontsize='large')  # 调整位置和字体大小
# plt.title("Cloud Type Distribution on a Spherical Projection", fontsize=14)
#
# # 显示图形
# plt.show()

''''合并数据'''
# import pandas as pd
#
# # 读取两个 CSV 文件
# df1 = pd.read_csv('/home/liudd/deeplearing/backup/prediction_ocean6_2020010104_results.csv', low_memory=False)
# df2 = pd.read_csv('/home/liudd/deeplearing/backup/prediction_ocean5_2020010104_results.csv', low_memory=False)
# df3 = pd.read_csv('/home/liudd/deeplearing/backup/prediction_ocean4_2020010104_results.csv', low_memory=False)
# df4 = pd.read_csv('/home/liudd/deeplearing/backup/prediction_ocean3_2020010104_results.csv', low_memory=False)
# df5 = pd.read_csv('/home/liudd/deeplearing/backup/prediction_ocean2_2020010104_results.csv', low_memory=False)
#
# # 合并两个 DataFrame
# merged_df = pd.concat([df1, df2, df3, df4, df5], ignore_index=True)
#
# # 将合并后的 DataFrame 保存为新的 CSV 文件
# merged_df.to_csv('ocean_merged_2020010104_11.15.csv', index=False)
''''云层厚度'''
# import pandas as pd
# import matplotlib.pyplot as plt
# from mpl_toolkits.basemap import Basemap
#
# # 读取数据
# data = pd.read_csv("ocean_merged_2020010104_11.15.csv")  # 替换为你的数据文件路径
# data = data[data['fy_cbh'] >= 0]
# data = data[data['fy_cot'] >= 0]
# # 获取经纬度和云顶高度信息
# latitude = data["fy_lat"]
# longitude = data["fy_lon"]
# cot = data["fy_cot"]
#
# # 创建球面投影
# plt.figure(figsize=(10, 10))
# m = Basemap(projection='ortho', lat_0=0, lon_0=104.7, resolution='l')  # 以 (0, 104.7) 作为中心
#
# # 绘制地图背景
# m.drawcoastlines()
# m.drawcountries()
# # 添加经纬度线
# parallels = range(-90, 91, 30)  # 每30度一个纬线
# meridians = range(-180, 181, 30)  # 每30度一个经线
# m.drawparallels(parallels, labels=[1, 0, 0, 0], color='gray', dashes=[1, 1], fontsize=10)
# m.drawmeridians(meridians, labels=[0, 0, 0, 1], color='gray', dashes=[1, 1], fontsize=10)
#
# # 将经纬度转换为地图坐标
# x, y = m(longitude.values, latitude.values)
#
# # 绘制云顶高度，使用散点图
# # 这里我们使用云顶高度的值来设置点的颜色和大小
# scatter = m.scatter(x, y, c=cot, s=50, cmap='Blues', marker='s',  alpha=0.7)
#
#
# # 添加颜色条
# plt.colorbar(scatter, label='Cloud Optical Thickness (COT)')
#
# # 添加标题
# plt.title('Cloud Optical Thick Distribution')
#
# # 显示图形
# plt.show()

''''云底高度'''
# import pandas as pd
# import matplotlib.pyplot as plt
# from mpl_toolkits.basemap import Basemap
# from matplotlib.colors import Normalize
#
# # 读取数据
# data = pd.read_csv("ocean_merged_2020010104_11.15.csv")  # 替换为你的数据文件路径
# data = data[data['fy_cbh'] >= 0]
# data = data[data['fy_cot'] >= 0]
# # 获取经纬度和云顶高度信息
# latitude = data["fy_lat"]
# longitude = data["fy_lon"]
# cbh = data["fy_cbh"]
#
# # 创建球面投影
# plt.figure(figsize=(10, 10))
# m = Basemap(projection='ortho', lat_0=0, lon_0=104.7, resolution='l')  # 以 (0, 104.7) 作为中心
#
# # 绘制地图背景
# m.drawcoastlines()
# m.drawcountries()
#
# # 添加经纬度线
# parallels = range(-90, 91, 30)  # 每30度一个纬线
# meridians = range(-180, 181, 30)  # 每30度一个经线
# m.drawparallels(parallels, labels=[1, 0, 0, 0], color='gray', dashes=[1, 1], fontsize=10)
# m.drawmeridians(meridians, labels=[0, 0, 0, 1], color='gray', dashes=[1, 1], fontsize=10)
#
# # 将经纬度转换为地图坐标
# x, y = m(longitude.values, latitude.values)
#
# # 根据云顶高度的最小值和最大值调整色带
# norm = Normalize(vmin=cbh.min(), vmax=cbh.max())  # 归一化云顶高度数据
#
# # 绘制云顶高度，使用散点图
# scatter = m.scatter(x, y, c=cbh, s=10, cmap='coolwarm', marker='s', alpha=0.7, norm=norm)
#
# # 添加颜色条
# plt.colorbar(scatter, label='Cloud Base Height (CBH)')
#
# # 添加标题
# plt.title('Cloud Base Height Distribution')
#
# # 显示图形
# plt.show()
